home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-04 | 3.5 KB | 82 lines | [TEXT/EDIT] |
- LightSpeed - A space flight toy, by Jonathan Birge. Gotten to run
- in Think Pascal and C, and Metrowerks C and Pascal by Kenneth A. Long,
- at itty bitty bytes(tm).
-
- -------------------------------------------------------------------
-
- Each one of these is different. The Think Pascal was the first one.
-
- The Metrowerks Pascal one has a full with direction indicator cross-
- hair.
-
- Steering is done with the numeric key pad.
-
- 4, 7, 8, 9, 6, 3, 2 and 1 all steer. The 5 key puts the "stick" in
- neutral (straight ahead). The '+' key accelerates by a factor of
- .01 and the '-' key reverses that. The '0' key stops.
-
- The 'Q' quits and the space bar fires "photon torpedoes." I didn't
- bothe getting the sound to work on any of them.
-
- -------------------------------------------------------------------
- "Lightspeed" was a Pascal source sent to me by Jonathan Birge,
- in response to a request I made for starfield source. This was
- prompted by seeing a nicely done "space flight" scene in the about
- box of his program "Digital Camera."
-
- I had no Pascal compiler at the time, so I attempted a C port. I
- got the photons working and the sound, and it made one-pixel stars
- that "twinkled" randomly. The cross-sight worked but key hits did
- nothing, except for 'Q'.
-
- Someone on AOL built an application for me with his Pascal compiler
- and I saw that the sight did not show on that one, yet the stars
- worked as in the included one, here. I couldn't figure out what was
- so bogus about my port.
-
- Then I got Think Pascal and thought if I could run it in ThP and
- look at the values in the debugger, I could spot the differences in
- the Think C debugger and fix it. But in ThP it would not step.
-
- Then I got Code Warrior, which has a great debugger, and I thought
- if I could run it in MW Pascal, in the debugger, I could finally get
- in to run right in Think C. No such luck. Something else was wrong
- (which I later figured out, witness the MWP port).
-
- Think Pascal is MUCH easier to operate than MWP, although I finally
- got it whoopped, too.
-
- What finally happened was I did the port all over again, and it ran
- even different this time. But the "Size" variable always came out
- with a value of 12 after the initial LoadStars routine ran. That
- variable is in the MakeRect routine, which determines the size of
- the star rectangles. It comes from some math involving random gen.
- routines. So, I determined that the random routines were putting
- out something bogus.
-
- On closer inspection, I determined the 'extended' type was the bug.
- In Think Pascal it's a 16 byte (96 bit) variable. In Think C it's
- a 10 byte (80 bit) struct. So, any way I tried it I'd either get
- compile errors or a crash.
-
- So, I got to thinking: "If the random generted values are 96 bits
- in size, for proper running, then why not get it to generate some
- that are a lower harmonic of that and store them in a smaller
- variable that I *DO* have (easily)." Yes, I could do the 80xTo96X
- thing (or whatever it is) if I *knew* how - but I don't. So I have
- to settle for the "stop-gap" method.
-
- I did, and dumped a few 'abs' calls and sized down the some of the
- variables to 'doubles' and I got it working! Not as cool as the
- Think Pascal one, but working just the same. My deductive reasoning
- with no help from anyone (but me) have paid off again. Lots of real
- programmers may look at the C source and think of all sorts of ways
- to improve it. If you do then *please* do! Then send it to me.
-
- Anyway, it's not a perfect port, but HEY! It's C source! It does
- not run perfectly but it does run!
-
- Enjoy!
-
- kenlong@netcom.com
-